package com.ruoyi.web.controller.mail;

import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.util.List;
@Service
public class MailServiceImpl implements MailService {

    @Autowired
    private MailAccount mailAccount;

    @Override
    public void sendText(String to, String subject, String content) {
        MailUtil.send(mailAccount, to, subject, content, false);
    }

    @Override
    public void sendHtml(String to, String subject, String htmlContent) {
        MailUtil.send(mailAccount, to, subject, htmlContent, true);
    }

    @Override
    public void sendWithAttachments(String to, String subject, String content, List<File> attachments) {
        MailUtil.send(mailAccount, to, subject, content, false, attachments.toArray(new File[0]));
    }


}
